<template>
  <div>
    <div id="piqianGS">
      <div class="content">
        <div class="list">
          <van-form validate-first>
            <p class="subTitle"><span class="line"></span>规划批前公示</p>
            <upLoad :rowData="rowData" :FJData="FJData1" :isReadOnly="false" :SHITUID="'98bcf528966e48ce896a8b3fd02d45d5'"
              :UpLoadID="'7a3fc061c866434b8475d3775c9ddcea'" />
            <inputSelect :isShowCity="false" :contentData.sync="gsjlData" :JFData.sync="NewformData" :title="'公示结论'"
              @getButtons="getButton" @getValues="getValues" />
            <inputSelect :isShowCity="false" :contentData.sync="gsyjData" :JFData.sync="NewformData" :title="'公示意见'"
              @getButtons="getButton" @getValues="getValues" />
          </van-form>
        </div>
      </div>
      <div class="footer">
        <van-button style="margin-right: 26px;width: 25vw;" size="small" type="info"
          @click="saveOrUpdateData('submit')">提交</van-button>
        <van-button style="margin-right: 26px;width: 25vw;" size="small" type="info"
          @click="saveOrUpdateData()">保存</van-button>
        <van-button style="margin-right: 10px;width: 25vw;" size="small" type="info">地图</van-button>
      </div>
      <!--发送-->
      <sendTree :rowData="rowData" :isshow.sync="showsendPage" :handleSelectClose="handleSelectClose" />
    </div>
  </div>
</template>

<script>
import {
  QuerySignCallback,
  dataTransFile,
  FileServerProxy,
  dataTransFilePreview,
  GetFileData,
} from "@/utils/api";
import FileData from '@/components/activity/FileData'
//下拉框、输入框、日期、单选框、多选框
import inputSelect from '../public/inputSelect'
//eca的文件上传组件 可上传 删除 预览pdf
import upLoad from '@/utils/upLoad'
import timeFormat from '@/utils/timeFormat.js'
import { GSA_Add, GSA_Search, addDate } from '@/common/commonApi'
import sendTree from "../public/sendTree.vue";
export default {
  filters: {
  },
  data() {
    return {
      rowData: "",
      FJData1: [
        {
          title: '规划批前公示远景照片',
          FileName: [],
          groupGuid: '2411faea-87d7-4754-98dd-8816c19d9909',
          fileList: []
        },
        {
          title: '规划批前公示近景照片',
          FileName: [],
          groupGuid: '9a1d4f18-bbc2-474c-b029-c3dae700600d',
          fileList: []
        },],
      gsjlData: [{
        label: '公示结论',
        key: 'GSJL',
        ISinput: false,
        required: true,
        readonly: true,
        isTime: false,
        emitData: '84f533f1-d64e-4193-8c61-706aad255536',
        NYDARR: []
      },],
      gsyjData: [{
        label: '公示意见',
        key: 'GSYJ', //绑定的字段
        ISinput: true, //true:输入框
        required: true, //true: 必填项
        readonly: true, //true:可以填写 false：不可以填写
        isTime: false //true:可以时间选择器 false：下拉框
      }],
      NewformData: [{
        PKID: "",
        TO_ROW_GUID: "",
        GSJL: "",
        GSYJ: "",
        JBR: "",
        JBRSJ: "",
      }],
      IsAdd: false,
      showsendPage: false,
    };
  },
  watch: {},
  components: {
    FileData, inputSelect,
    upLoad,
    sendTree
  },
  computed: {},
  created() {
    if (this.$route.query.data) {
      this.rowData = JSON.parse(this.$route.query.data);
    }
  },
  methods: {
    handleSelectClose() {
      this.showsendPage = false;
    },
    getButton(name, val, key) { },
    getValues() { },
    async getData() {
      //查询
      let data = [
        { field: 'to_row_guid', value: this.rowData.ROW_GUID }
      ]
      const resNoData = await GSA_Search('789aa94a-5119-416f-87aa-e40b09ac6b50', data)
      if (resNoData.Data && resNoData.Data.length > 0) {
        this.NewformData = resNoData.Data
        this.IsAdd = false;
      } else {
        this.IsAdd = true
      }
    },
    async saveOrUpdateData(type) {
      let me = this
      if (me.IsAdd) {
        me.NewformData[0].TO_ROW_GUID = me.rowData.ROW_GUID
        me.NewformData[0].JBR = JSON.parse(window.localStorage.getItem('userName')).userName
        me.NewformData[0].JBRSJ = timeFormat(null, 'yyyy-mm-dd hh:MM:ss');
        me.NewformData[0].eca_RowState = 'added'
      } else {
        me.NewformData[0].eca_RowState = 'modified'
      }
      //组织成需要表单的信息
      let data1 = {
        '789aa94a-5119-416f-87aa-e40b09ac6b50': [me.NewformData[0]]
      }
      let par = {
        formData: JSON.stringify(data1)
      }
      let params1 = {
        accessCode: '688bd3883572440a859dfd8ba9194e7b11',
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '',
        params: par
      }
      let resdata = await FileServerProxy(params1)
      debugger
      if (resdata.data.data && JSON.parse(resdata.data.data).Success) {
        me.IsAdd = false

        if (type == 'submit') {
          me.showsendPage = true;
        } else {
          me.$toast.success('保存成功!')
        }
      } else {
        me.IsAdd = true;
        me.$toast.success('保存失败!')
      }

    },
  },
  mounted() {
    //设置title
    if (ZWJSBridge) {
      ZWJSBridge.setTitle({
        title: "粤政易",
      })
        .then((res) => {
        })
        .catch((err) => {
        });
    }

    //当前行数据
    this.getData();
  },
  updated() { },
};
</script>

<style lang="scss" scoped>
#piqianGS {
  height: 95vh;
  background: rgb(255, 255, 255);
  font-size: 18px;

  .content {
    width: 100%;
    height: calc(100% - 50px);
    overflow: auto;
    padding: 10px;

    .subTitle {
      width: 100%;
      height: 50px;
      line-height: 50px;
      font-size: 16px;
      position: relative;
      display: flex;
      align-items: center;
      padding-left: 10px;
      color: #3f8ffc;

      .line {
        width: 6px;
        height: 26px;
        background: #3f8ffc;
        display: inline-block;
        margin-right: 10px;
      }
    }
  }

  .footer {
    text-align: center;
  }
}
</style>
<style lang="scss">
#piqianGS {
  .van-cell {}

  .van-cell--required::before {
    left: 0;
    font-size: 20px;
  }

  .van-field__label {
    color: black;
  }

  .GSJL {
    .van-field__control {
      text-align: right;
    }
  }
}
</style>
